<template>
  <div class="ycdwrap" id="ycdwrap">
    <div class="yc-table-wrp">
      <div>
        <yc-title class="title" value="IP商列表"></yc-title>
      </div>
    <!--   <div class="acc-man-body">
        <label class="yc-table">IP商列表</label>
        <el-input maxlength="30" v-model="barCode"  class="input"></el-input>
        <label class="yc-table">IP商列表</label>
        <yc-search-button @click="handleSearch"></yc-search-button>
      </div> -->
      <el-form modle="form" :inline="true">
        <el-form-item label="IP商名称">
          <el-input placeholder="请输入IP商名称"></el-input>
        </el-form-item>
      </el-form>
      <yc-table :total="total" :tableData="tableInfo"></yc-table>
    </div>
  </div>
</template>

<script>
import request from 'request'
import ycTable from './com/table'
import ycTitle from '@/components/ycTitle'
import ycInput from '@/components/yc-input'
import ycSearchButton from '@/components/searchButton'
const { resetDate } = require('@/utils/tool')
export default {
  name: 'menuManage',
  components: {
    ycTable,
    ycTitle,
    ycSearchButton,
    ycInput
  },
  data () {
    return {
      tableInfo: [],
      total: null,
      barCode: '',
      startDate: '',
      endDate: '',
      pickerStartDate: { // 时间约束开始时间不能大于结束时间
        disabledDate: time => {
          if (this.endDate) {
            return time.getTime() > this.endDate
          }
        }
      },
      pickerCloseDate: { // 结束时间不能小于开始时间
        disabledDate: time => {
          return time.getTime() < this.startDate
        }
      }
    }
  },
  methods: {
    handleSearch () {
      this.init()
    },
    init (val) {
      let t = ''
      let end = ''
      if (this.startDate) {
        t = resetDate(this.startDate)
      }
      if (this.endDate) {
        end = resetDate(this.endDate)
      }
      request.getProduct({
        params: {
          endDate: end || '',
          p: val || 1,
          productCode: this.barCode || '',
          size: 10,
          startDate: t || ''
        }
      }).then(res => {
        this.tableInfo = res.records
        this.total = res.total
      })
    }
  },
  mounted () {
    this.init()
  }
}
</script>

<style lang="stylus" scoped="scoped">
.yc-table-wrp{
  .acc-man-body{
    display flex
    align-items center
    padding 20px 0 0 0
    margin 0 0 40px 0
  }
  .newadd{
    float right
    margin 20px 0
  }
}
#ycdwrap
  .acc-man-body
    .yc-table
      min-width 104px
</style>
